import React from "react";
function Text2(props) {
  return (
    <div>
      123
      {props.title}
      {props.children()}
      <button
        onClick={() => {
          props.btn();
        }}
      >
        新增
      </button>
    </div>
  );
}
class Views_index extends React.PureComponent {
  constructor() {
    super();
    this.state = {
      arr: [1, 2, 3],
    };
  }
  add = () => {
    console.log(1);
    let arr = JSON.parse(JSON.stringify(this.state.arr));
    arr.push(4);
    this.setState(() => {
      return {
        arr: arr,
      };
    });
  };
  render() {
    return (
      <div>
        默认显示
        <Text2 title={"ss"} btn={this.add.bind(this)}>
          {() => {
            return this.state.arr.map((res) => {
              return <p key={res + "ss"}>{res}</p>;
            });
          }}
        </Text2>
      </div>
    );
  }
}
export default Views_index;
